package swingUI;

import java.util.Date;
import java.util.List;

import com.trsjh.db.domains.CustomerAccount;

import mySwingToolkit.model.ClassModel;
import mySwingToolkit.model.SwitchedTableModel;
import mySwingToolkit.ui.TableView;

public class CustomerAccountViewUI extends TableView<CustomerAccount> {
	// SwitchedTableModel<CustomerAccount> sm=;
	
	public CustomerAccountViewUI(List<CustomerAccount> customers,int size) {
		super(new SwitchedTableModel<CustomerAccount>(
				new Object[][] {
				},
				new String[] {
						"主账号", "登录名", "姓名", "性别", "注册日期", "配镜次数","剩余积分","操作"
				},
				new Class[] {
						String.class, String.class, String.class, String.class, Date.class, Integer.class,Float.class,String.class
				},
				new boolean[] {
						false, false, false, false, false, false,false,false
				},false,false,false,size
				){
			private static final long serialVersionUID = 1L;
			@Override
			public Object[] translate(
					ClassModel<CustomerAccount> object) {
				CustomerAccount c=object.getObject();
				return new Object[]{object,this.getRowCount()+1,c.getCustomer().getPhone(),c.getLoginName(),c.getName(),c.getSex().equals('m')?"男":"女",c.getRegisterTime(),c.getCustomerRecords().size(),c.getLeftScore(),"记录详情"};
			}
			@Override
			public CustomerAccount constructObject(int row,
					int col) {
				// TODO Auto-generated method stub
				return null;
			}
			@Override
			public void initNullRow(int row) {
				// TODO Auto-generated method stub
				
			}
		});
		this.initDatas(customers);
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = 4679412633748520431L;

}
